home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / ALLFIELD.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  78 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _AllFields(cFileName,cSepChar,cFieldFunc) --> cFieldNameString
  8.  
  9. PARAMETERS:
  10.  
  11. cFileName  : Name of database file to extract field names from
  12. cSepChar   : Delimiter character (Optional : ',' default)
  13. cFieldFunc : Field Function (Optional : Default = none)
  14.  
  15. SHORT:
  16.  
  17. Create a string expression containing all database field names.
  18.  
  19. DESCRIPTION:
  20.  
  21. _AllFields() returns a string of all field names in the database
  22. specified delimited with the character passed in cSepChar.
  23.  
  24. If cSepChar is not specified, the default delimiter is "," (comma).
  25.  
  26. cFieldFunc is a function to apply to each field name.  If not specified,
  27. no function is applied.  The Field Name MUST be represented by <!> in order
  28. to allow multiple function nesting around the field name.  If there
  29. were always to be a single function applied, you could simply specify the
  30. name of the function and _allfields() could supply the necessary "()".
  31. But since, in the case of "LTRIM(STR())", _allfields() will need to know
  32. that the field name should be placed inside the first ")", not the last.
  33.  
  34. See example.
  35.  
  36. NOTE:
  37.  
  38. LTRIM(STR(<!>)) is different from SUBSTR(<!>,1,5) in placement of the
  39. field name.
  40.  
  41. See examples.
  42.  
  43. If the specified database is open in any work area, _AllFields() switches
  44. to that area, uses the file, creates the string and restores the
  45. original current work area when done.
  46.  
  47. If the specified database is not open in any area, then the string
  48. in cFileName is used as an explicit file name to open the database.
  49.  
  50. EXAMPLE:
  51.  
  52. Assume TEST.DBF is open in one of the open work areas.  _AllFields() will use
  53. the alias to SELECT the proper work area:
  54.  
  55. t = _AllFields('TEST')
  56.  
  57. Result: t = 'FIELD1,FIELD2,FIELD3'
  58.  
  59. Assume TEST.DBF is NOT open in ANY work area.  In this case, you must supply
  60. the DATABASE FILE NAME to be USED:
  61.  
  62. t = _AllFields('TEST.DBF','+')
  63.  
  64. Result: t = 'FIELD1+FIELD2+FIELD3'
  65.  
  66.  
  67. // These two example specify a FIELD FUNCTION:
  68.  
  69. t = _AllFields("TEST.DBF",'+',"TRIM(<!>)")
  70.  
  71. Result: t = "TRIM(FIELD1)+TRIM(FIELD2)+TRIM(FIELD3)"
  72.  
  73. t = _AllFields("TEST.DBF",'+',"LTRIM(STR(<!>,0))")
  74.  
  75. Result: t = "LTRIM(STR(FIELD1,0))+LTRIM(STR(FIELD2,0))..." etc.
  76.  
  77. ******************************************************************************/
  78.